package com.example.edu.coupon.strategy.impl;

import com.example.edu.coupon.strategy.MeetMinus;
import com.example.edu.coupon.strategy.QuoteStrategy;

import java.math.BigDecimal;

public class MeetMinusQuoteStrategy implements QuoteStrategy<MeetMinus> {

    @Override
    public BigDecimal quote(MeetMinus meetMinus, BigDecimal price) {

        if (price.compareTo(meetMinus.meetAmount) < 0) {
            return price;
        }
        price = price.subtract(meetMinus.discountAmount);
        if (price.compareTo(BigDecimal.ZERO) <= 0) {
            return BigDecimal.ZERO;
        }
        return price;
    }
}
